<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>网站后台</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="__ADMIN__css/font.css">
    <link rel="stylesheet" href="__ADMIN__css/xadmin.css">
    <script type="text/javascript" src="__ADMIN__js/jq.js"></script>
    <script type="text/javascript" src="__ADMIN__lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="__ADMIN__js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="__ADMIN__html5.min.js"></script>
    <script src="__ADMIN__respond.min.js"></script>
    <![endif]-->
</head>
<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="/admin.php">首页</a>
         <a href=""> <cite>数据库管理</cite></a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<xblock>
    <a class="layui-btn" id="addSql" ><i class="layui-icon"></i>添加</a>
    <span class="x-right" style="line-height:40px">共有数据：88 条</span>
</xblock>
<div class="x-body">
    <table class="layui-table x-admin">
        <thead>
        <tr>
            <th>序号</th>
            <th>备份名称</th>
            <th>备份时间</th>
            <th>备份大小</th>
            <th>操作</th>
        </thead>
        <tbody>
        {volist name='list' id='vo'}
        <tr id="tr_{$vo.name}">
            <td>{$key+1}</td>
            <td>{$vo.name}</td>
            <td>{$vo.time}</td>
            <td>{$vo.size}</td>
            <td width="25%">
                <a  href="{:url('index',['type'=>'dowonload','name'=>$vo.name])}" class="btn layui-btn"><span class="bold">下载</span></a>
                <a  href="javascript:;"   sql="{$vo.name}"  class="btn layui-btn restoresql"><span class="bold">还原</span></a>
                <a href="javascript:;"   sql="{$vo.name}"   class="btn layui-btn destory"> <span class="bold">删除</span></a>
            </td>
        </tr>
        {/volist}


        </tbody>
    </table>
    <div class="page">
        <div>

        </div>
    </div>

</div>
<script>
    $('#addSql').click(function () {
        layer.confirm('确认要进行备份操作吗？',function(index){
            //发异步删除数据
            $.ajax({
                type:'post',
                data:{type:'backup'},
                dataType:'json',
                url:"{:url('admin/backup/index')}",
                success:function (data) {
                    if (data.code == 0){
                        layer.alert("本次操作花费"+data.message, {icon: 6},function () {
                            location.replace(location.href);
                        });
                    }else{
                        layer.alert(data.message, {icon: 5});
                        return false;
                    }
                }
            })
        });
    });

    $('.destory').click(function () {
        var name = $(this).attr('sql');
        layer.confirm('确认要删除吗？',function(index){
            //发异步删除数据
            $.ajax({
                type:'post',
                data:{type:'del',name:name},
                dataType:'json',
                url:"{:url('admin/backup/index')}",
                success:function (data) {
                    if (data.code == 0){
                        layer.msg('已删除!',{icon:6,time:1000},function () {
                            location.replace(location.href);
                        });
                    }else{
                        layer.alert(data.message, {icon: 5});
                        return false;
                    }
                }
            })
        });
    });
    $('.restoresql').click(function () {
        var name = $(this).attr('sql');
        layer.confirm('确认还原此数据吗？',function(index){

            $.ajax({
                type:'post',
                data:{type:'restore',name:name},
                dataType:'json',
                url:"{:url('admin/backup/index')}",
                success:function (data) {
                    if (data.code == 0){
                        layer.alert(data.message,{icon:6,time:1000});
                    }else{
                        layer.alert(data.message, {icon: 5});
                        return false;
                    }
                }
            })
        })
    });


</script>

</body>

</html>